<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("车辆列表")}</title>
<link href="/resources/css/common.css" rel="stylesheet" type="text/css" />
<link href="/resources/css/zTreeStyle.css" rel="stylesheet" type="text/css">
<link href="/resources/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/resources/css/mmGrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/jquery.js"></script>
<script type="text/javascript" src="/resources/js/base/dialog.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.validate.js"></script>
<script type="text/javascript" src="/resources/js/base/request.js"></script>
<script type="text/javascript" src="/resources/js/base/global.js"></script>
<script type="text/javascript" src="/resources/js/reference/mmGrid.js"></script>
<script type="text/javascript" src="/resources/plugin/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.ztree.excheck-3.5.js"></script>
<!--地图-->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=xzQ89rGL61tuBjTdlQCRRlShOQ9WLTNd"></script>
<script type="text/javascript" src="/resources/js/mapJs/map_baidu.js"></script>
<link href="/resources/js/mapJs/map_baidu.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/mapJs/DistanceTool_min.js"></script>

<script type="text/javascript">
var dragging  = 0;
var dragDoc = null;
var dragbtn;
var begin_height = 0;
var end_height = 0;
var height__spec = 0;
var total_height;
function createDragDoc(callback){
	if(dragDoc==null){
		var leftOffset = 0;
		dragDoc  = document;
		dragDoc.onmousemove = function(e){
			clickX = e.pageX;
			if(clickX>0){
				if (dragging==1) {
					//第一个拖动按钮左边不出界
					if(clickX > leftOffset) {
						if(clickX<130 || clickX>700){
							return false;
						}
						var prev = dragbtn.prev();
						var next = dragbtn.next();
						var w = prev.width();
						var prev_w = clickX;
						var spec = prev_w-w;

						//dragbtn.prev().width( prev_w + 'px');
						dragbtn.css('left', dragbtn.offset().left+spec + 'px');//按钮移动
						next.css('left',  next.offset().left+spec + 'px');
						prev.width( (next.offset().left-4) + 'px');
						
						end_height = $("#search-content").height();
						height__spec = begin_height-end_height;
						begin_height = end_height;
						if(height__spec!=0){
							//changeGridHeightX(height__spec);
						}
					}
				}else if(dragging==2){
					clickY = e.pageY;
					//第一个拖动按钮左边不出界
					if(clickY > leftOffset) {
						
						var prev = dragbtn.prev().prev().prev().prev().prev();
						var next = dragbtn.next();
						var prev_old_h = prev.height();
						var prev_h = clickY-prev.offset().top;
						var spec = prev_h - prev_old_h;
						var next_h = total_height-prev_h;
						if(prev_h<100 || next_h<100){
							return false;
						}
						prev.height(prev_h);
						next.height(next_h);

						if(spec!=0){
							changeGridHeightY();
						}
					}
				}
			}
		};

		$(dragDoc).mouseup(function(e) {
			dragging = 0;
			e.cancelBubble = true;
			$("body").removeClass("resize-ing").removeClass("resize-y");
		})
	}
}

function dragX(){
	var clickX, leftOffset, inx, nextW2, nextW;
	var labBtn 	  = $("#labBtn");
	var wrapWidth = $("body").width();
	
	labBtn.bind('mousedown',function(){
			dragging   = 1;
			dragbtn = $(this);
			leftOffset = 0;
			inx 	   = $(this).index('label');
			begin_height = $("#search-content").height();
			$("body").addClass("resize-ing");
		}
	);
	createDragDoc();
}

function changeGridHeightX(h_spec){
	var $bodyWrapper = $(".mmg-bodyWrapper");
	var $responsive =  $(".table-responsive");
	var $mmGrid = $(".mmGrid");
	
	$bodyWrapper.height($bodyWrapper.height()+h_spec);
	$responsive.height($responsive.height()+h_spec);
	$mmGrid.height($mmGrid.height()+h_spec);
	
}


function dragY(total_height){
		var clickY, leftOffset, inx, nextW2, nextW;
		var labBtn 	  = $("#labBtn-y");
		var wrapWidth = $("body").width();
		
		var begin_height = 0;
		var end_height = 0;
		var height__spec = 0;
	
		labBtn.bind('mousedown',function(){
				dragging   = 2;
				dragbtn = $(this);
				leftOffset = 0;
				$("body").addClass("resize-y");
			}
		);
		createDragDoc();
		
}
function changeGridHeightY(){

	var $tabContent = $(".tabContent:visible");
	var top = $tabContent.offset().top;  
	var total_height = $(window).height();
	var h1 = total_height-top-2;
	var h2 = h1-$tabContent.find(".mmg-headWrapper").height();
	var h3 = h1-2
	$(".table-responsive").height(h1);
	$(".mmg-bodyWrapper").height(h2);
	$(".mmGrid").height(h3);
}
</script>
<script type="text/javascript">
//车辆列表
var $tcGrid;
function initCarGrid(){
	var colsCar = [
		{ title:'${message("操作")}', align:'center',width:50, renderer:function(val,item,rowIndex,obj){
			return '<a href="javascript:;" class="deleteElock btn-delete">删除</a>';
		}},				
		{ title:'${message("车牌号")}', name:'car_number' ,align:'center',renderer:function(val,item,rowIndex){
			var valStr = '<input type="hidden" class="elock_id" value="2_'+item.elock_id+'"/>' + val;
			return valStr;
		}},
		{ title:'${message("车辆状态")}', name:'car_status' ,align:'center',renderer:function(val,item,rowIndex){
			return '在线';
		}},
		{ title:'${message("锁编号")}', name:'elock_num' ,align:'center', width:60},
		{ title:'${message("舱位")}', name:'position' ,align:'center',renderer:function(val,item,rowIndex){
			var berth=item.berth;
			var position=item.position;
			return (berth==null?'':berth)+','+(position==null?'':position);
		}},
    	{ title:'${message("锁状态")}', name:'status' ,align:'center',renderer:function(val,item,rowIndex){
			return val==1?"开锁：在线":"锁定：不在线";
		}},
		{ title:'${message("状态信息描述")}', name:'status_desc' ,align:'center', width:110},
		{ title:'${message("经度")}', name:'longitude' ,align:'center'},
		{ title:'${message("纬度")}', name:'latitude' ,align:'center'},
		{ title:'${message("基站定位数据")}', name:'jzdw' ,align:'center', },
    	{ title:'${message("海拔高度")}', name:'altitude' ,align:'center'},
    	{ title:'${message("速度")}', name:'speed' ,align:'center'},
    	{ title:'${message("方向")}', name:'direction' ,align:'center'},
    	{ title:'${message("GPS时间")}', name:'gps_time' ,align:'center',width:120},
		{ title:'${message("备注")}', name:'remark' ,align:'center', width:110}
	];
	$tcGrid=$('#table-car').mmGrid({
		fullWidthRows:true,
        cols: colsCar,
        checkCol: false,
        useLoading:false,
        url: 'getElockData.jhtml',
        params:function(){
        	return $("#listForm").serializeObject();
        }
    });
}

//钥匙列表
var $tkGrid;
function initKeyGrid(){
	var colsk = [	
		{ title:'${message("操作")}',width:50, align:'center', renderer:function(val,item,rowIndex,obj){
			return '<a href="javascript:;" class="deleteTerminal btn-delete">删除</a>';
		}},			
   		{ title:'${message("终端设备编号")}', name:'terminal_num' ,align:'center',renderer:function(val,item,rowIndex){
			var valStr = '<a href="javascript:void(0);" onClick="showTerminalInfo(this,'+item.terminal_id+')" class="red">'+val+'</a><input type="hidden" class="terminal_id" value="3_'+item.terminal_id+'"/>';
			return valStr;
		}},
		{ title:'${message("SIM卡号")}', name:'sim' ,align:'center'},
		{ title:'${message("版本号")}', name:'version' ,align:'center'},
   		{ title:'${message("是否在线")}', name:'is_online' ,align:'center',renderer:function(val,item,rowIndex){
			return val==0 ? "离线" : "在线";
   		}},
       	{ title:'${message("上线时间")}', name:'online_time' ,align:'center',width:120},
       	{ title:'${message("状态信息描述")}', name:'status_desc' ,align:'center', width:110},
       	{ title:'${message("电压")}', name:'vol' ,align:'center'},
   		{ title:'${message("经度")}', name:'longitude' ,align:'center'},
   		{ title:'${message("纬度")}', name:'latitude' ,align:'center'},
   		{ title:'${message("基站定位数据")}', name:'jzdw' ,align:'center', },
       	{ title:'${message("海拔高度")}', name:'altitude' ,align:'center'},
       	{ title:'${message("速度")}', name:'speed' ,align:'center'},
       	{ title:'${message("方向")}', name:'direction' ,align:'center'},
       	{ title:'${message("GPS时间")}', name:'gps_time' ,align:'center',width:120},
   		{ title:'${message("备注")}', name:'remark' ,align:'center', width:110}
   	];
   	$tkGrid=$('#table-m2').mmGrid({
		fullWidthRows:true,
        cols: colsk,
        checkCol: false,
        useLoading:false,
        url: 'getTerminalData.jhtml',
        params:function(){
       	 return $("#listForm").serializeObject();
        }
   });
}

//事件列表
var $tmGrid;
function initTerminalGrid(isDisabled){
	var cols = [				
		{ title:'${message("终端设备编号")}', name:'terminal_num' ,align:'center',renderer:function(val,item,rowIndex){
			var valStr = '<input type="hidden" value="1_'+item.terminal_num+'"/>' + val;
			return valStr;
		}},
		{ title:'${message("事件信息")}', name:'event_message' ,align:'center', width:250},
		{ title:'${message("状态信息描述")}', name:'status_desc' ,align:'center', width:110},
		{ title:'${message("报警信息")}', name:'warning_message' ,align:'center', width:110},
		{ title:'${message("事件发生时间")}', name:'event_time' ,align:'center', width:120},
		{ title:'${message("处理人")}', name:'processor' ,align:'center'},
		{ title:'${message("任务单流水号")}', name:'task_sn' ,align:'center', width:80},
		{ title:'${message("车牌号")}', name:'car_number' ,align:'center'},
		{ title:'${message("锁编号")}', name:'elock_num' ,align:'center'},
		{ title:'${message("舱位")}', name:'position' ,align:'center',renderer:function(val,item,rowIndex){
			var berth=item.berth;
			var position=item.position;
			return (berth==null?'':berth)+','+(position==null?'':position);
		}},
		{ title:'${message("经度")}', name:'longitude' ,align:'center', },
		{ title:'${message("纬度")}', name:'latitude' ,align:'center', },
		{ title:'${message("基站定位数据")}', name:'jzdw' ,align:'center', },
		{ title:'${message("电压")}', name:'vol' ,align:'center', width:60},
		{ title:'${message("海拔高度")}', name:'altitude' ,align:'center', width:60},
		{ title:'${message("速度")}', name:'speed' ,align:'center', width:60},
		{ title:'${message("方向")}', name:'direction' ,align:'center', width:60},
		{ title:'${message("GPS时间")}', name:'gps_time' ,align:'center', width:120}
	];
	$tmGrid=$('#table-terminal').mmGrid({
		fullWidthRows:true,
        cols: cols,
        checkCol: false,
        url: 'getMessageEventData.jhtml?maxcount=100',
        params:function(){
        	return $("#listForm").serializeObject();
        },
        callback:function(){
        	if(isDisabled){
        		$(".message").prop("disabled", false).removeClass("_disabled");
        		$(".eventRefresh").prop("disabled", false).removeClass("_disabled");
        	}
        }
    });
}

$().ready(function() {

	var top = $(".tabContent").eq(0).offset().top;  
	var total_height = $(window).height();
	$(".table-responsive").height(total_height-top-2);

	initCarGrid();
	
	//初始化给定列表的高度
	var $tabContent = $(".tabContent:visible");
	var top = $tabContent.offset().top;  
	var total_height = $(window).height();
	var h1 = total_height-top-2;
	var h2 = h1-$tabContent.find(".mmg-headWrapper").height();
	var h3 = h1-2
	$(".table-responsive").height(h1);
	$(".mmg-bodyWrapper").height(h2);
	$(".mmGrid").height(h3);
	
	//删除车辆列表数据
	$(".deleteElock").live("click", function() {
		deleteHandle(this,0);
	});

	//删除钥匙列表数据
	$(".deleteTerminal").live("click", function() {
		deleteHandle(this, 1);
	});
	
	//整行触发右键事件
	$(".real-row").live("contextmenu",function(e){
		terminalRightClick(e,$(this));
		return false;
	});
});

//删除车辆、钥匙数据
function deleteHandle(e, type) {
	var zTree = $.fn.zTree.getZTreeObj("js-menu");
	var nodes = zTree.getCheckedNodes(true);
	var id = type == 0 ? $(e).closest("tr").find(".elock_id").val() : $(e).closest("tr").find(".terminal_id").val();
	for (var i = 0; i < nodes.length; i++) {
		var treeNode = nodes[i];
 		if (id == treeNode.id) {
	 		zTree.checkNode(treeNode, false, true, true);
	 		break;
	 	}
 	}
}

//钥匙列表右键菜单
function terminalRightClick(event,e) {
	var zTree = $.fn.zTree.getZTreeObj("js-menu");
	var nodes = zTree.getCheckedNodes(true);
	var terminal_id = $(e).find(".terminal_id").val();
	for (var i = 0; i < nodes.length; i++) {
		var treeNode = nodes[i];
 		if (terminal_id == treeNode.id) {
	 		ztreeOnRightClick(event, null, treeNode);
	 		break;
	 	}
 	}
	return false;
}


function searchAgain(index){
	$("#tab input").removeClass("current").eq(index).addClass("current");
	var $tabContent = $(".tabContent").hide();
	$tabContent.eq(index).show();
	$("#typeFlag").val(index);
	$(".mmGrid").height($(".table-responsive").eq(index).height()-2);
	if (index == 1 && initKeyGridCount == 0) {
		initKeyGrid();
		initKeyGridCount++;
	}
	//事件刷新按钮
	if (index == 2) {
		$(".eventRefresh").show();
		getMessageEventData(true);
	} else {
		$(".eventRefresh").hide();
	}
}
</script>
<script type="text/javascript">
$().ready(function(e) {
	
 	var zTree = $("#js-menu").initTree({
		url: "/saleOrg/getNodes.jhtml?stat=1",
		onClick: ztreeOnClick,
		onCheck: ztreeOnCheck,
		onAsyncSuccess: function(e, treeId, treeNode) {
			var rootNodes = zTree.getNodes();
		 	for (var i = 0; i < rootNodes.length; i++) {
		 		zTree.expandNode(rootNodes[i],true,false,false);
		 	}
		 	if (treeNode != undefined && treeNode.checked) {
		 		zTree.checkNode(treeNode, true, true, true);
		 	}
			window.setTimeout(function(){
				var nodes = zTree.transformToArray(treeNode);
		 		changeIcon(0, nodes);
		 	}, 500);
		},
		onRightClick: ztreeOnRightClick
	})
    //zTree.addNodes(null,{'id':'','pId':'','name':'全部机构','isParent':false, 'nocheck':false,'halfCheck':true});
 	treeScoll();

 	total_height = $(window).height()-$("#labBtn-y").height()-4;	
 	dragX();
	dragY(total_height);
 	
 	//根据是否在线等改变图标
 	window.setInterval(function(){
 		changeIcon(0);
 		window.setTimeout(function(){
	 		getElockData();
	 	}, 1500);
	 	window.setTimeout(function(){
	 		getTerminalData();
	 	}, 3000);
 	}, 30000);

 	$("#rMenu ul").live("click", function() {
		$("#rMenu").css({"visibility" : "hidden"});
	});

	$("#heartbeat").live("change",function() {
		if (this.checked) {
			if ($(".heartbeat").hasClass("shownone")){
				$(".heartbeat").removeClass("shownone");
				$("input[name='heartbeat']").attr("disabled",false);
			} 
		} else {
			if (!$(".heartbeat").hasClass("shownone")){
				$(".heartbeat").addClass("shownone");
				$("input[name='heartbeat']").attr("disabled",true);
			} 
		}
	});
	$("#addrport").live("change",function() {
		if (this.checked) {
			if ($(".addrport").hasClass("shownone")) {
				$(".addrport").removeClass("shownone");
				$("input[name='serverAddr']").attr("disabled",false);
				$("input[name='tcpPort']").attr("disabled",false);
				$("input[name='udpPort']").attr("disabled",false);
			};
		} else {
			if (!$(".addrport").hasClass("shownone")) {
				$(".addrport").addClass("shownone");
				$("input[name='serverAddr']").attr("disabled",true);
				$("input[name='tcpPort']").attr("disabled",true);
				$("input[name='udpPort']").attr("disabled",true);
			};
		}
	});
	$("#gpstime").live("change",function() {
		if (this.checked) {
			if ($(".gpstime").hasClass("shownone")) {
				$(".gpstime").removeClass("shownone");
				$("input[name='gpsTime']").attr("disabled",false);
			};
		} else {
			if (!$(".gpstime").hasClass("shownone")) {
				$(".gpstime").addClass("shownone")
				$("input[name='gpsTime']").attr("disabled",true);
			};
		}
	});

	$("input[name='heartbeat']").live("blur",function() {
		var c=$(this); 
	    if(/[^\d]/.test(c.val())){//替换非数字字符  
	      var temp_amount=c.val().replace(/[^\d]/g,'');
	      if (temp_amount == "" || temp_amount < 60) {
	      	temp_amount = 60;
	      }
	      $(this).val(temp_amount);
	    }
	    if ($(this).val() < 60) {
	    	$(this).val(60);
	    }
	});

	$("input[name='gpsTime']").live("blur",function() {
		var c=$(this); 
	    if(/[^\d]/.test(c.val())){//替换非数字字符  
	      var temp_amount=c.val().replace(/[^\d]/g,'');
	      if (temp_amount == "") {
	      	temp_amount = 30;
	      }
	      $(this).val(temp_amount);
	    }
	});
});

//获取车辆锁数据
function getElockData() {
	var typeIds = $("#typeIds").val();
	if (typeIds.indexOf("2_") > -1) {
		ajaxSubmit(0,{
			method:'post',
			url:"getElockData.jhtml",
			data: $("#listForm").serialize(),
			callback: function(data) {
				if (data.content != null && data.content.length > 0) {
					var content = eval('(' + data.content + ')'); 
					for (var i = 0; i < content.length; i++) {
		        		var item = content[i];
		    //     		if (i == 0) {
						// 	$("input[name='elockDate']").val(item.modify_date);
						// }
		        		var index = $("input[value='2_"+item.elock_id+"']").closest("tr").index();
		        		if (index == -1) {
		        			$tcGrid.addRow(item);
		        		} else {
							$tcGrid.updateRow(item, index);
		        		}
		        	}
				}
			}
		});
	}
}

//获取钥匙数据
var initKeyGridCount = 0;
function getTerminalData() {
	if (initKeyGridCount == 0) {
		initKeyGrid();
		initKeyGridCount++;
	}
	var typeIds = $("#typeIds").val();
	if (typeIds.indexOf("3_") > -1) {
		ajaxSubmit(typeFlag,{
			method:'post',
			url:"getTerminalData.jhtml",
			data: $("#listForm").serialize(),
			callback: function(data) {
				if (data.content != null && data.content.length > 0) {
					var content = eval('(' + data.content + ')'); 
					// var searchDate = data.objx;
					// if (searchDate != null) {
					// 	$("input[name='terminalDate']").val(searchDate);
					// }
					for (var i = 0; i < content.length; i++) {
		        		var item = content[i];
		        		var index = $("input[value='3_"+item.terminal_id+"']").closest("tr").index();
		        		if (index == -1) {
		        			$tkGrid.addRow(item);
		        		} else {
							$tkGrid.updateRow(item, index);
		        		}
		        	}
				}
			}
		});
	}
}

//获取事件数据
var initTerminalGridCount = 0;
function getMessageEventData(isDisabled) {
	if(isDisabled){
		if($(".message").hasClass("_disabled"))return false;
		$(".message").prop("disabled", true).addClass("_disabled");
		if($(".eventRefresh").hasClass("_disabled"))return false;
		$(".eventRefresh").prop("disabled", true).addClass("_disabled");
	}
	if (initTerminalGridCount == 0) {
		initTerminalGrid(isDisabled);
		initTerminalGridCount++;
	}
	$tmGrid.load();
}

//点击事件
function ztreeOnClick(e,treeId, treeNode) {
	//点击时勾选复选框
	// var zTree = $.fn.zTree.getZTreeObj("js-menu");
	//zTree.checkNode(treeNode, true, true, true);
	
	$("#oid").val(treeNode.oid);
	$("#type").val(treeNode.type);
	if (treeNode.type == 1 || treeNode.type == 2) {
		searchAgain(0);
	} else if (treeNode.type == 3) {
		searchAgain(1);
	}
	//清掉之前创建的标注
	bmap.map.clearOverlays();

	if (treeNode.type == 2 || treeNode.type == 3) {
		ajaxSubmit($(e),{
			method:'post',
			url:"/realtime_monitor/getRealtimePosition.jhtml",
			data: {id: treeNode.oid, type: treeNode.type},
			callback: function(data) {
				var item=data.objx;
				if (item.longitude!=null && item.latitude!=null){
					setMarker(item, treeNode);
					showRangeFences(item.latitude, item.longitude);
				}
			}
		});
	} else if (treeNode.type == 1) {
// 		var content= '<form id="editForm" action="update_info.jhtml" method="post" type="ajax" validate-type="validate"><table class="input" style="width:65%;margin-left:30px;">'
// 			+'<tbody>'
// 			+'<tr class="title_tr"><td class="title_td">${message("4舱")}</td><td class="title_td">${message("3舱")}</td><td class="title_td">${message("2舱")}</td><td class="title_td">${message("1舱")}</td></tr>'
// 			+'<tr class="top_tr"><td class="top_td">上4</td><td class="top_td">上3</td><td class="top_td">上2</td><td class="top_td">上1</td></tr>'
// 			+'<tr class="bottom_tr"><td class="bottom_td">下4</td><td class="bottom_td">下3</td><td class="bottom_td">下2</td><td class="bottom_td">下1</td></tr>'
// 			+'</tbody></table></form>';
		var content= '<div class="content">'
			+'<div class="title"><div class="title_4"></div><div class="title_3"></div><div class="title_2"></div><div class="title_1"></div></div>'
			+'<div style="margin-top: 47px;float: left;margin-left: 18px;">'
			+'<div class="berth_4 div_inline">'
			+'<div class="top_div"><div class="top_img img"></div><div class="top_span span">&nbsp;</div></div>'
			+'<div class="bottom_div"><div class="bottom_span span">&nbsp;</div><div class="bottom_img img"></div></div>'
			+'</div>'
			+'<div class="berth_3 div_inline">'
			+'<div class="top_div"><div class="top_img img"></div><div class="top_span span">&nbsp;</div></div>'
			+'<div class="bottom_div"><div class="bottom_span span">&nbsp;</div><div class="bottom_img img"></div></div>'
			+'</div>'
			+'<div class="berth_2 div_inline">'
			+'<div class="top_div"><div class="top_img img"></div><div class="top_span span">&nbsp;</div></div>'
			+'<div class="bottom_div"><div class="bottom_span span">&nbsp;</div><div class="bottom_img img"></div></div>'
			+'</div>'
			+'<div class="berth_1 div_inline">'
			+'<div class="top_div"><div class="top_img img"></div><div class="top_span span">&nbsp;</div></div>'
			+'<div class="bottom_div"><div class="bottom_span span">&nbsp;</div><div class="bottom_img img"></div></div>'
			+'</div>'
			+'</div></div>';
		var $dialog = $.dialog({
			title:'${message("车辆视图")}',
			width:640,
			height:350,
			ok:null,
			cancel:null,
			content: content,
			onShow:function(){
				$.ajax({
					url: "/car/getElockCar.jhtml",
					type: "POST",
					data: {carId : treeNode.oid},
					dataType: "json",
					cache: false,
					async:false, 
					success: function(data) {
						var items = data.objx;
						for(var i=0;i<items.length;i++){
							var item=items[i];
							var position=item.position=="上"?".top_div":".bottom_div";
							$(".title_"+item.berth).css("background","none");
							var $div=$(".berth_"+item.berth).find(position);
							$div.find(".span").html(item.elockNum);
							if(item.status!=null){
								if(item.status==1){
									$div.find(".img").css("background","url(/resources/images/elock_off.png) no-repeat");
									$div.find(".img").css("background-size","25px 25px");
								}
								else{
									$div.find(".img").css("background","url(/resources/images/elock_on.png) no-repeat");
									$div.find(".img").css("background-size","25px 25px");
									
								}
							}
						}
					}
				});
				
			},
			onOk:function(){

			}
		});
		$dialog.css("top","100px");
	}
}

//展示钥匙信息
function showTerminalInfo(e, terminal_id) {
	var zTree = $.fn.zTree.getZTreeObj("js-menu");
	var nodes = zTree.getCheckedNodes(true);
	for (var i = 0; i < nodes.length; i++) {
		var treeNode = nodes[i];
 		if (terminal_id == treeNode.oid && treeNode.type == 3) {
	 		ztreeOnClick(e, null, treeNode);
	 		break;
	 	}
 	}
}

var preInfoWindow;
//设置覆盖物
function setMarker(item, treeNode, preMarker) {
	//跳转并显示自定义图标
	var pp = new BMap.Point(item.longitude, item.latitude);//里面的参数(经度、纬度)  
	bmap.map.centerAndZoom(pp, 18);//18，是地图显示放大缩小等级，越大越具体
	var myIcon = new BMap.Icon("/resources/images/"+treeNode.iconSkin+"_map.png", new BMap.Size(30,30),{imageSize:new BMap.Size(30,30)});//这个参数是图片的参数
	var marker = new BMap.Marker(pp,{icon:myIcon});
	if (preMarker != null) {
		bmap.map.removeOverlay(preMarker);
	}
	bmap.map.addOverlay(marker);//添加标注
	var title = "";
	var vol = "";
	var fence = "";
	var fences = "";
	var height = 190;
	var width = 400;
	if (item.elock_num!=null) {
		title = "<b>" + "锁号："+ item.elock_num + "</b>";
	}
	else if (item.terminal_num!=null) {
		var isOnline = item.is_online==1?"是":"否";
		var version = item.version == null ?"":item.version;
		title = "<label><b>" + "终端设备编号："+ item.terminal_num + "</b></label><label><b>版本号："+version+"&nbsp;&nbsp;&nbsp;&nbsp;在线："+isOnline+"</b></label>";
		vol = "<label>电压：" + item.vol + "</label>";
		// fence = '<br><div class="red viewFence" style="float:left;cursor:pointer;">电子围栏查看<div class="in-sidenav">';
		fence = '<br><a class="red" href="/realtime_monitor/track_history.jhtml?terminalNum='+item.terminal_num+'" target="_blank">轨迹回放</a>';
		height = 190;

		// ajaxSubmit($(title),{
		// 	method:'post',
		// 	url:"/electronic_fence/getElectronicFence.jhtml",
		// 	data: {terminalId: item.terminal_id},
		// 	async:false,
		// 	callback: function(data) {
		// 		var itemList=data.objx;
		// 		fence+='<ul><li id="terminal-title"><span style="color:#939393;font-size:12px;margin-left:40px;">选择电子围栏</span/></li>';
		// 		for (var i = 0; i < itemList.length; i++) {
		// 			var iitem = itemList[i];
		// 			if (iitem.type == 1) {
		// 				var electronic_fence_name= iitem.electronic_fence_name.length>7?iitem.electronic_fence_name.substring(0,7)+'...':iitem.electronic_fence_name;
		// 				fence += '<li style="padding:10px" onMouseOver="this.style.background=\'#e7e7e7\'" onMouseOut="this.style.background=\'#FCFCFC\'" title="'+iitem.electronic_fence_name+'"><a href="javascript:void(0);" onclick="showElectronicFence(&apos;'+iitem.points+'&apos;)">'+electronic_fence_name+'</a></li>';
		// 			} else {
		// 				fence += '<li style="padding:10px" onMouseOver="this.style.background=\'#e7e7e7\'" onMouseOut="this.style.background=\'#FCFCFC\'" title="'+iitem.electronic_fence_name+'"><a href="javascript:void(0);" onclick="showElectronicFence(null,'+iitem.longitude+','+iitem.latitude+','+iitem.radius+')">'+electronic_fence_name+'</a></li>';
		// 			}
		// 		}
		// 		fence+='</ul>';
		// 	}
		// });
		// fence += '</div></div>&nbsp;&nbsp;&nbsp;&nbsp;<a class="red" href="javascript:;" onclick="viewElectronicFence(this,'+item.terminal_id+',1)">电子围栏清除</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="red" href="/realtime_monitor/track_history.jhtml?terminalNum='+item.terminal_num+'" target="_blank">轨迹回放</a>';
	}
	var info = "<div class='terminalInfo' style='text-align:left;line-height:2; height:"+height+"px; width:"+width+"px;border-top: solid 2px #02aae9;'>";
	info += "<label>基站定位数据：" + item.jzdw + "</label>";
	info += "<label>GPS时间：" + item.gps_time + "</label>";
	info += vol;
	info += "<label>速度：" + item.speed + "</label>";
	info += "<label>方向：" + item.direction + "</label>";
	info += "<label>海拔高度：" + item.altitude + "</label>";
	if (item.terminal_num!=null) {
		info += "<br>SIM卡号：" + item.sim;
	}
	info += "<br>状态信息：" + item.status_desc;
	info += fence;
	info += "</div>";
	var opts = {
	  width : width,     // 信息窗口宽度
	  height: height,     // 信息窗口高度
	  offset: new BMap.Size(0, 0),
	  title : title , // 信息窗口标题
	  enableMessage:true//设置允许信息窗发送短息
	}
	var infoWindow = new BMap.InfoWindow(info, opts);  // 创建信息窗口对象 
	bmap.map.openInfoWindow(infoWindow,pp); //开启信息窗口
	marker.addEventListener("click", function(){          
		bmap.map.openInfoWindow(infoWindow,pp); //开启信息窗口
	});
	preInfoWindow = infoWindow;
}

//选择事件
function ztreeOnCheck(e,treeId, treeNode) {

	if (!treeNode.checked) {
		if(treeNode.isParent && treeNode.type == 1) {
			var children = treeNode.children;
			for (var i = 0; i < children.length; i++) {
				var index = $("input[value='"+children[i].id+"']").closest("tr").index();
				if(index != -1 && children[i].type == 2) {
					$tcGrid.removeRow(index);
				}
			}
		} else {
			var index = $("input[value='"+treeNode.id+"']").closest("tr").index();
			if(index != -1 && treeNode.type == 2) {
				$tcGrid.removeRow(index);
			} else if(index != -1 && treeNode.type == 3) {
				$tkGrid.removeRow(index);
			} 
		}
	}

	var treeObj = $.fn.zTree.getZTreeObj("js-menu");
    var nodes = treeObj.getCheckedNodes(true);
    var msg = "";
    for (var i = 0; i < nodes.length; i++) {
    	if (nodes[i].type == 1 || nodes[i].type == 2 || nodes[i].type == 3) {
    		msg += ";" + nodes[i].type + "_"+nodes[i].oid;
    	}
    }
    if (msg != "") {
    	msg = msg.substring(1);
    }
    $("#typeIds").val();
    $("#typeIds").val(msg);

    if (treeNode.type == 1 || treeNode.type == 2) {
		searchAgain(0);
		getElockData();
	} else if (treeNode.type == 3) {
		searchAgain(1);
		getTerminalData();
	}
}

//改变图标
function changeIcon(needCheck, changeNodes) {
	
	var zTree = $.fn.zTree.getZTreeObj("js-menu");
	var nodes = [];
	var typeIds = "";
	if (changeNodes == null) {
		// nodes = zTree.transformToArray(zTree.getNodes());
		var $li = $("#js-menu li:visible");
		$li.each(function () {
			$this = $(this);
			var node = zTree.getNodeByTId($this.attr("id"));
			if (node.type > 0) {
	    		typeIds += ";" + node.id;
	    		nodes.push(node);
	    	}
		});
	} else {
		for (var i = 0; i < changeNodes.length; i++) {
	    	var node = changeNodes[i];
	    	if (node.type > 0) {
	    		typeIds += ";" + node.id;
	    	}
	    }
	    nodes = changeNodes;
	}
    if (typeIds != "") {
    	typeIds = typeIds.substring(1);
    }
    if (typeIds == "") return false;
    // var elockStatusDate = $("input[name='elockStatusDate']").val();
    // var terminalStatusDate = $("input[name='terminalStatusDate']").val();
    ajaxSubmit($(needCheck),{
		method:'post',
		url:"/realtime_monitor/getStatus.jhtml",
		data: {typeIds: typeIds},
		callback: function(data) {
			var itemList=data.objx;
			if (itemList.length > 0) {
				for (var i = 0; i < nodes.length; i++) {
					var treeNode = nodes[i];
					var type = treeNode.type;
					var id = treeNode.oid;
			    	for (var n = 0; n < itemList.length; n++) {
			    		var item = itemList[n];
						if (id == item.id && type == item.type) {

							if (type == 1 && item.status != null) {
								// treeNode.iconSkin = item.status == 1?"car_online":"car_offline";
							}
							if (type == 2 && item.status != null) {
								treeNode.iconSkin = item.status == 1?"elock_online":"elock_offline";
								// if (n==0) {
								// 	$("input[name='elockStatusDate']").val(item.modify_date);
								// }
							}
							if (type == 3 && item.status != null) {
								treeNode.iconSkin = item.status == 1?"terminal_online":"terminal_offline";
								// if (n==0) {
								// 	$("input[name='terminalStatusDate']").val(item.modify_date);
								// }
							}
							zTree.updateNode(treeNode);
							break;
						}
					}
			    }
			}
		}
	});
}

function sendMessage(sendType){
	var rid = $("#rid").val();
	var rname = $("#rname").val();
	
	var title = "设备控制操作";
	if (sendType == 1) {
		title = "终端参数设置";
	}

	var type = sendType == 0 ? 34304 : 33027; //0x8600 0x8103
	var h = "350";
	var content = '<form id="sendForm"><table class="input input-edit" style="width:100%">'
				+'<tbody>'
				+'<tr><th>终端设备：</th><td colspan="2">'+rname+'<input type="hidden" name="terminalId" value="'+rid+'">'
				+'<input type="hidden" name="type" value="'+type+'"></td></tr>';
	if (sendType == 0) {
		content += '<tr><th>下发内容：</th><td colspan="2">'
				+'<label><input type="radio" name="content" value="15" checked="checked" />允许关机</label>'
				+'<label><input type="radio" name="content" value="14"/>立即关机</label>'
				+'<label><input type="radio" name="content" value="13"/>重启系统</label>'
				+'<label><input type="radio" name="content" value="12"/>重启GPS模块</label>'
				+'<label><input type="radio" name="content" value="11"/>系统升级</label>'
				+'<label><input type="radio" name="content" value="10"/>钥匙禁止使用</label>'
				+'<label><input type="radio" name="content" value="9"/>钥匙恢复使用</label></td></tr>';
	} else {
		h = "480";
		content += '<tr><th>操作类型：</th><td colspan="2"><label style="width: 80px;"><input type="checkbox" id="heartbeat" />心跳时间</label>'
				+'<label><input type="checkbox" id="addrport"/>IP和端口设置</label>'
				+'<label><input type="checkbox" id="gpstime"/>定位有效时长</label></td></tr>'
				+'<tr><th style="height:179px">操作内容：</th><td colspan="2"><div class="heartbeat shownone"><span>终端心跳发送间隔(秒)：</span><input type="text" class="text" name="heartbeat" value="60" disabled/></div>'
				+'<div class="addrport shownone"><span>备份服务器地址：</span><input type="text" class="text" name="serverAddr" disabled/></div>'
				+'<div class="addrport shownone"><span>服务器TCP端口：</span><input type="text" class="text" name="tcpPort" disabled/></div>'
				+'<div class="addrport shownone"><span>服务器UDP端口：</span><input type="text" class="text" name="udpPort" disabled/></div>'
				+'<div class="gpstime shownone"><span>GPS定位有效时长(秒)：</span><input type="text" class="text" name="gpsTime" value="30" disabled/></div></td></tr>';
	}
	content += '<tr><th>执行情况：</th><td><div id="sendText" style="height:160px;"><div></td>'
			+'<td style="width:60px;"><div id="timerSpan" style="display:none;"><div id="timerDesc">计时：</div><div id="timerValue" style="text-align: center;">0</div></div></td></tr>'
			+'</tbody></table></form>';

	var $dialog_check = $.dialog({
		title:title,
		height: h,
		width:'600',
		content: content,
		ok: "发送",
		cancel: "关闭",
		onOk:function(){
 			if (!$(".cancleButton").hasClass("shownone")) {
 				$(".cancleButton").addClass("shownone");
 			}
 			if (!$(".sureButton").hasClass("shownone")) {
 				$(".sureButton").addClass("shownone");
 			}
			$.ajax({
				url: "/realtime_monitor/send_msg.jhtml",
				type: "POST",
				data: $("#sendForm").serialize(),
				dataType: "json",
				cache: false,
				async:false, 
				success: function(data) {
					if (data.type == "error") {
						$.message_alert(data.content);
						if ($(".cancleButton").hasClass("shownone")) {
				 			$(".cancleButton").removeClass("shownone");
				 		}
				 		if ($(".sureButton").hasClass("shownone")) {
				 			$(".sureButton").removeClass("shownone");
				 		}
						return false;
					}
					$("input[type='radio']").attr("disabled",true); 
					$("input[type='text']").attr("readonly",true);
					$("#sendText").empty();
					$("#sendText").append("<div>平台发送数据中.........</div>");
					var messageSendId = data.objx;
					var sendSuccess = false;
					var replySuccess = false;
					var timerSign = 0;
					var sendT;
					var replyT;
					var timer = window.setInterval(function() {
						if (timerSign == 0) {
							sendT = showTimer(timer, 12, 0);
						}
						timerSign++;

						$.ajax({
							url: "/realtime_monitor/get_message_send.jhtml",
							type: "POST",
							data: {id : messageSendId},
							dataType: "json",
							cache: false,
							async:false, 
							success: function(data) {
								var item = data.objx;
								if (!sendSuccess && item.send_result > 0) {
									sendSuccess = true;
									if (item.send_result == 1) {
										$("#sendText").append("<div style='color:greed;'>发送成功：" + item.send_message + "</div>");
										window.clearInterval(sendT);
										replyT = showTimer(timer, 12, 1);
										$("#sendText").append("<br><div>平台等待接收终端回复数据............</div>");
									} else if (item.send_result == 2) {
										$("#sendText").append("<div style='color:red;'>发送异常：" + item.send_message + "</div>");
										$("#timerSpan").hide();
										window.clearInterval(sendT);
										window.clearInterval(timer);
										setElementStatus(true);
										return false;
									}
								}
								if (!replySuccess && item.reply_result == 1) {
									$("#sendText").append("<div style='color:greed;'>终端回复：" + item.reply_message + "</div>");
									replySuccess = true;

									$("#timerSpan").hide();
									window.clearInterval(replyT);
									window.clearInterval(timer);
									setElementStatus(true);
									return false;
								}
							}
						});
					}, 1000);
				}
			});
			return false;
		}
	});
	var h = 80;
	$dialog_check.css("top",h+"px");
	$(".dialogClose").addClass("shownone");
}

function ztreeOnRightClick(event, treeId, treeNode) {
	if (treeNode.type == 3 && !treeNode.noR) {
		$("#rid").val(treeNode.oid);
		$("#rname").val(treeNode.name);
		$("#li-span-title").html(treeNode.name);
		showRMenu(event.clientX, event.clientY);
	}
}
function showRMenu(x, y) {
	$("#rMenu ul").show();
    y += document.body.scrollTop;
    x += document.body.scrollLeft;
	var btm=$(window).height()-(y+120);
	if(btm<0){
    $("#rMenu").css({"top":(y-30+btm)+"px", "left":x+"px", "visibility":"visible"});
	}else{
    $("#rMenu").css({"top":(y-30)+"px", "left":x+"px", "visibility":"visible"});
	}
	$("body").bind("mousedown", onBodyMouseDown);
	
}
function hideRMenu() {
	if ($("#rMenu")) $("#rMenu").css({"visibility": "hidden"});
	$("body").unbind("mousedown", onBodyMouseDown);
}
function onBodyMouseDown(event){
	if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length>0)) {
		$("#rMenu").css({"visibility" : "hidden"});
	}
}

function showTimer(timer, time, type) {

	var c = 1;
	$("#timerValue").text(c);
	$("#timerSpan").show();
	var t = window.setInterval(function() {
		$("#timerValue").text(c);
		c++;
		if (c >= time) {
			window.clearInterval(t);
			window.clearInterval(timer);
			$("#timerSpan").hide();
			var txt = type == 0 ? '<div style="color:red;">发送异常：下发数据超时，点击"发送"按钮可重试</div>' : '<div  style="color:red;">接收异常：平台接收终端回复数据超时，点击"发送"按钮可重试</div>';
			$("#sendText").append(txt);
			setElementStatus(true);
			return false;
		}
	}, 1000);
	return t;
}

function setElementStatus(isShow) {

	if (isShow) {
		$("input[type='radio']").attr("disabled",false); 
		$("input[type='text']").attr("readonly",false);
		if ($(".cancleButton").hasClass("shownone")) {
 			$(".cancleButton").removeClass("shownone");
 		}
 		if ($(".sureButton").hasClass("shownone")) {
 			$(".sureButton").removeClass("shownone");
 		}
	} else {
 		$("input[type='radio']").attr("disabled",true); 
 		$("input[type='text']").attr("readonly",true);
 		if (!$(".cancleButton").hasClass("shownone")) {
 			$(".cancleButton").addClass("shownone");
 		}
 		if ($(".sureButton").hasClass("shownone")) {
 			$(".sureButton").removeClass("shownone");
 		}
	}
}

var polygons = [];
function viewElectronicFence(e, id, type) {

	if (type == 0) {
		
	} else {
		for(var i=0; i<polygons.length; i++) {
	        bmap.map.removeOverlay(polygons[i]);
	    }
	    polygons = [];
	}
}

function showRangeFences(latitude, longitude) {
	ajaxSubmit($(1),{
		method:'post',
		url:"/electronic_fence/getRangeFences.jhtml",
		data: {latitude: latitude, longitude: longitude, distance: 3000},
		callback: function(data) {
			var fences = data.objx;
			if (fences != null && fences.length > 0) {
				var parm = {
					strokeColor : "red", //边线颜色。
					fillColor : "red", //填充颜色。当参数为空时，圆形将没有填充效果。
					strokeWeight : 3, //边线的宽度，以像素为单位。
					strokeOpacity : 0.8, //边线透明度，取值范围0 - 1。
					fillOpacity : 0.3, //填充的透明度，取值范围0 - 1。
					strokeStyle : 'solid' //边线的样式，solid或dashed。
				};
				for (var i = 0; i < fences.length; i++) {
					var fence = fences[i];
					var marker;
					if (fence.type == 0) {
						marker = new BMap.Circle(new BMap.Point(fence.longitude,fence.latitude), fence.radius, parm);
					} else {
						var points = fence.points;
						var pointsArray=points.split(",");
						var newarray = [];
					    for(var n=0;n<pointsArray.length;n+=2) {
					        newarray.push(new BMap.Point(pointsArray[n+1],pointsArray[n]));
					    }
					    marker = new BMap.Polygon(newarray, parm);
					}
					bmap.map.addOverlay(marker);

					var point = marker.getBounds().getCenter();
					var label = new BMap.Label(fence.name + "<br>(" + fence.sale_org_name + ")", {position : point, offset:new BMap.Size(0,0)});
					label.setStyle({fontFamily:"微软雅黑"});
					bmap.map.addOverlay(label);
				}
			}
		}
	});
}

function showElectronicFence(points,longitude,latitude,radius) {
	for(var i=0; i<polygons.length; i++) {
        bmap.map.removeOverlay(polygons[i]);
    }
	polygons = [];
	var polygon;
	var parm = {
		strokeColor : "red", //边线颜色。
		fillColor : "red", //填充颜色。当参数为空时，圆形将没有填充效果。
		strokeWeight : 3, //边线的宽度，以像素为单位。
		strokeOpacity : 0.8, //边线透明度，取值范围0 - 1。
		fillOpacity : 0.3, //填充的透明度，取值范围0 - 1。
		strokeStyle : 'solid' //边线的样式，solid或dashed。
	};
	if (points != null) {
		var pointsArray=points.split(",");
		var newarray = [];
	    for(var n=0;n<pointsArray.length;n+=2) {
	        newarray.push(new BMap.Point(pointsArray[n+1],pointsArray[n]));
	    }
	    polygon = new BMap.Polygon(newarray, parm);
		bmap.map.addOverlay(polygon);
		polygons.push(polygon);
		preInfoWindow.close();
		// 以最佳的视图显示轨迹坐标
		var viewport = bmap.map.getViewport(newarray);
		bmap.map.centerAndZoom(viewport.center, viewport.zoom);
	} else {
		polygon = new BMap.Circle(new BMap.Point(longitude,latitude), radius, parm);
		bmap.map.addOverlay(polygon);
		polygons.push(polygon);
		preInfoWindow.close();
		// 以最佳的视图显示轨迹坐标
		var viewport = bmap.map.getViewport(new BMap.Point(longitude,latitude));
		bmap.map.centerAndZoom(viewport.center, viewport.zoom);
	}
}
</script>
<style type="text/css">
div.floatDiv,.shownone {
	display: none;
}
.input-edit label {
	width: 100px;
	display: inline-block;
	margin-bottom: 5px;
}
#timerSpan {
	color: red;
}
#timerValue {
	font-size: 50px;
}
#timerDesc {
	font-size: 20px;
}
#sendForm div input.text {
	width: unset;
}
#sendForm div span {
	width: 150px;
	display: inline-block;
}
.heartbeat,.addrport,.gpstime {
	margin: 5px 0;
}
div.tabContent{
	float:left;width:100%
}
.in-sidenav {
    position: absolute;
    border: solid 1px #E7E7E7;
    z-index: 999;
    background: #FCFCFC;
    border-radius: 5px;
    text-align: left;
    display: none;
    bottom: 20px;
    left:15px;
    box-shadow: 0 6px 12px rgba(0,0,0,.175);
    width:260px;
    cursor: auto;
}
.in-sidenav li{
	width:110px;
	display:inline-block;
	cursor: pointer;
}
.in-sidenav a {
    color: #666;
    display: block;
    height: 10px;
    line-height: 10px;
    font-size: 13px;
    position: relative;
}
.viewFence:hover .in-sidenav {
	display:block
}
.terminalInfo label, .BMap_bubble_title label {
    display: inline-block;
	width: 188px;
	margin-right: 10px;
}
#li-title{
	height: 20px;
	font-size: 14px;
	text-align: center;
	border-bottom: solid 2px #02aae9;
	color:#939393;
	background:url(/resources/images/under-16x16.png) no-repeat ;
	background-size:12px 12px;
	background-position:10px 50%;
}
#rMenu li{
	padding: 7px 15px;
}
#rMenu li:hover{
	background:#f5f5f5;
}
#li-title:hover{
	background:url(/resources/images/under-16x16.png) no-repeat !important;
	background-size:12px 12px !important;
	background-position:10px 50% !important;
}
#li-span-title{
	margin-left:10px;
	line-height:17px;
}
#terminal-title{
	background:url(/resources/images/terminal-under-16x16.png) no-repeat ;
	background-size:14px 14px;
	background-position:15px 50%;
	padding: 5px 0px;
	width:100%;
	border-bottom: solid 2px #02aae9;
	cursor: auto;
}

/* 车辆视图          */
.content{
	background:url(/resources/images/car_view.png) no-repeat;
	background-size:600px auto;
	height:250px;
	width:600px;
	margin-top:20px;
	margin-left:20px;
}
.div_inline{
	display:inline-block;
/* 	width:100px; */
	margin-left: 5px;
}
.div_inline div{
	height:37px;
	text-align:center;
	color: white;
}
div.title div{
	height:50px;
	display:inline-block;
	background:white;
}
div.title_1,div.title_4{
	width:25%;
}
div.title_2,div.title_3{
	width:20%;
}
div.top_div{
  	border-top:1px solid rgba(0,0,0,0);    	
  	border-left:1px solid rgba(0,0,0,0);  
  	border-right:1px solid rgba(0,0,0,0);  
/*    	background: #00beff;   */
/*   	padding-top:20px; */
}
div.bottom_div{
	line-height:47px;
  	border-bottom:1px solid rgba(0,0,0,0);  
  	border-left:1px solid rgba(0,0,0,0);  
  	border-right:1px solid rgba(0,0,0,0);  
/*    	background: #00beff;   */
/*   	padding-bottom:20px; */
}
.berth_1 div{
	width:115px;
}
.berth_2 div{
	width:117px;
}
.berth_3 div{
	width:117px;
}
.berth_4 div{
	width:120px;
}
.berth_4 .top_div{
	  border-top-left-radius: 25px;
      -moz-border-top-left-radius: 25px;
      -webkit-border-top-left-radius: 25px
}
.berth_4 .bottom_div{
	  border-bottom-left-radius: 25px;
      -moz-border-bottom-left-radius: 25px;
      -webkit-border-bottom-left-radius: 25px
}
.berth_1 .top_div{
	  border-top-right-radius: 25px;
      -moz-border-top-right-radius: 25px;
      -webkit-border-top-right-radius: 25px
}
.berth_1 .bottom_div{
	  border-bottom-right-radius: 25px;
      -moz-border-bottom-right-radius: 25px;
      -webkit-border-bottom-right-radius: 25px
}
div.top_img{
	width:25px;
	height:25px;
/* 	background:url(/resources/images/elock_on.png) no-repeat; */
	background-size:25px auto;
	margin-top:-17px;
}
div.bottom_img{
	width:25px;
	height:25px;
/* 	background:url(/resources/images/elock_on.png) no-repeat; */
	background-size:25px auto;
	margin-top:-7px;
}
.berth_1 div.img{
	margin-left:40px;
}
.berth_2 div.img{
	margin-left:45px;
}
.berth_3 div.img{
	margin-left:45px;
}
.berth_4 div.img{
	margin-left:47px;
}
/* end */
</style>
</head>
<body class="tree-contain">
<div class="subnav">
	<input type="hidden" id="flag" value="0">
	<input type="hidden" id="storeId" value="">
 	<div class="tit"><s></s>机构分类</div>
  	<div class="subn-list ztree" id="js-menu">
  	</div>
  	<div id="rMenu" class="flag-wrap flagImp-wrap">
		<input type="hidden" id="rid" value="">
		<input type="hidden" id="rname" value="">
		<ul class="flag-list">
			<li id="li-title"><span id="li-span-title"></span></li>
			<li><a href="javascript:void(0)" onclick="sendMessage(0)">设备控制操作</a></li>
			<li><a href="javascript:void(0)" onclick="sendMessage(1)">终端参数设置</a></li>
		</ul>
	</div>
</div>
<label id="labBtn"></label>
<div class="main-right">
	<form id="listForm" action="list.jhtml" method="get">
	<input type="hidden" id="type" name="type" value="">
	<input type="hidden" id="oid" name="oid" value="">
	<input type="hidden" id="typeIds" name="typeIds" value="">
	<input type="hidden" id="typeFlag" name="typeFlag" value="0">
	<input type="hidden" name="lastId" value="">
	<input type="hidden" name="elockDate" value="">
	<input type="hidden" name="terminalDate" value="">
	<input type="hidden" name="elockStatusDate" value="">
	<input type="hidden" name="terminalStatusDate" value="">
		<div class="search-btn" style="display:none">
			<a href="javascript:;" id="searchBtn" class="iconButton">${message("1004")}</a>
		</div>
		<div id="map" style="height:450px;width:100%;">
		</div>
			<input id="search" type="text" class="searchbox-content-common"/>
			<input type="button" id="" class="searchbox-content-common search_map button" onClick="search_key()"/>
			<div id="searchResultPanel" class="searchResultPanel"></div>
			
			<div class="ui3-control-wrap">
			<div class="left float-l"> 
			   <div class="trafficopt map" map-on-click="traffic"> 
			   		<ul>
				    <span class="span_map_type"></span>
				    <i>地图类型</i> 
				    </ul>
			   <div class="hidden-box-map" style="display:none;">
			    	<ul> 
				    	<span class="span_map1"></span>
					    <i style="color: #579AFC" onClick="bmap.changeMapType(BMAP_NORMAL_MAP);">平面地图</i> 
				  	</ul> 
				  	<ul> 
				    	<span class="span_map2"></span>
					    <i onClick="bmap.changeMapType(BMAP_HYBRID_MAP);">卫星地图</i> 
				  	</ul> 
				</div>
			   </div> 
			    <b></b>
			   <div class="trafficopt tool" map-on-click="traffic"> 
			   		<ul>
				    <span class="span_map_tool"></span>
				    <i>工具箱</i> 
				    </ul>
			   <div class="hidden-box-tool" style="display:none;">
				  	<ul> 
				    	<span class="span_map_ruler"></span>
					    <i onClick="bmap.opanRanging();">测距</i> 
				  	</ul> 
				</div>
			   </div>
			     <b></b>
			  <!--  <div class="trafficopt" map-on-click="traffic"> 
			   		<ul>
				    <span class="span_map3"></span>
				    <i>视图</i> 
				    </ul>
			   </div> -->
			    
		  </div>
		  </div>
		              
             
	<div id="labBtn-y" style="height: 10px;cursor: s-resize;"></div>   
	<div style="width:100%; float: left;" id="bottomDiv">
			<ul id="tab" class="tab tab-first">
		 	<li>
	            <input type="button" class="current" value="${message("车辆")}" onclick="searchAgain(0)">
	        </li>
  			<li>
	            <input type="button" value="${message("钥匙")}" onclick="searchAgain(1)">
	        </li>
	        <li>
	            <input type="button" value="${message("事件")}" class="message" onclick="searchAgain(2)">
	        </li>
	        <li>
	            <a href="javascript:;" class="eventRefresh btn-edit"  onclick="getMessageEventData(true)"  style="display:none;margin-top: 3px;">
	            	<img src="/resources/images/button/ico-break.png" style="margin-top: -2px;">&nbsp;刷新
	            </a>
	        </li>
	    </ul>
	    
	    <div class="tabContent needRealtimePosition" >
	    	<div class="table-responsive" >
			<table id="table-car"></table>
	    	<!-- <div  style="text-align:left;">
	    		<div id="paginator-car"></div>
	   		</div> -->
			</div>
		</div>
		<div class="tabContent needRealtimePosition" style="display:none;" >
			<div class="table-responsive" >
			<table id="table-m2"></table>
	    	<!-- <div  style="text-align:left;">
	    		<div id="paginator-m2"></div>
	   		</div> -->
			</div>
		</div>
		<div class="tabContent " style="display:none;" >
			<div class="table-responsive">
			<table id="table-terminal"></table>
	    	<!-- <div  style="text-align:left;">
	    		<div id="paginator-terminal"></div>
	   		</div> -->
			</div>
		</div>
	</div>
	</div>
		<!-- <div class="table-responsive" style="float:left;width:100%">
			<table id="table-terminal"></table>
	    	<div id="body-paginator" style="text-align:left;">
	    		<div id="paginator"></div>
	   		</div>
		</div> -->
	</form>
</body>
<script type="text/javascript">
/**
 * 实例化地图
 * 
 * 初始化地图id
 * 是否需要绘制区域
 * 是否需要定位
 * 是否需要大小按钮
 * 是否需要搜索按钮
 */
bmap.init('map',false,false,true,true);
				

</script>
</html>